import Mock from 'mockjs'

const List = []
const count = 10

for (let i = 0; i < count; i++) {
  List.push(Mock.mock({
    id: '@increment',
    name: 'John',
    avatar_url: '',
    availability_status: 'online'
  }))
}

export default [
  {
    url: '/api/v1/inbox_members',
    type: 'get',
    response: config => {
      const { importance, type, title, page = 1, limit = 1 } = config.query

      const mockList = List.filter(item => {
        if (importance && item.importance !== +importance) return false
        if (type && item.type !== type) return false
        if (title && item.title.indexOf(title) < 0) return false
        return true
      })

      const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))

      return {
        payload: pageList
      }
    }
  }
]

